



 <style>
     .jiage{ margin-left: 150px;}
 </style>



    <div class="fbneirong">
        <form class="am-form jdtask">


            <div class="am-form-group am-cf">
                <div class="zuo">商品链接：</div>
                <input type="hidden" name="id" value="<?php echo $id ?>">
                <div class="you">
                    <input type="text" class="myinput am-input-sm"  name="link"    value="<?php echo $link;  ?>"      placeholder="请输入链接">
                </div>
            <!--  <div    id="bufa" class="am-btn am-btn-secondary am-radius">再次发布</div>-->
            </div>
            <div class="am-form-group am-cf">
                <div class="zuo">店铺名：</div>
                <div class="you">
                    <input type="text"   name="shop_name" class="myinput am-input-sm" id="doc-ipt-email-1"   value="<?php echo $shop_name;  ?>"    placeholder="请输入商品名称">
                </div>
            </div>

            <div class="am-form-group am-cf">
                <div class="zuo"> 商品名称 ：</div>
                <div class="you">
                    <input type="text"   name="goods_name" class="myinput am-input-sm" id="doc-ipt-email-1"   value="<?php echo $goods_name;  ?>"    placeholder="请输入商品名称">
                </div>
            </div>

            <div class="am-form-group am-cf">

            <div class="zuo">搜索关键字：</div>
            <div class="you">
                <input type="text"   name="keyword" class="myinput am-input-sm" id="doc-ipt-email-1"   value="<?php echo $keyword;  ?>"    placeholder="请输入关键字">
            </div>
            </div>

            <div class="am-form-group am-cf">
                <div class="zuo">客单价：</div>
                <div class="zuo">
                    <input type="text"   name="price" class="myinput am-input-sm myinput2 " id="doc-ipt-email-1"   value="<?php echo $price;  ?>"    placeholder="请输入客单价">
                </div>
                <div class="zuo jiage">付款价格：</div>
                <div class="zuo">
                    <input type="text"   name="pay_price" class="myinput am-input-sm myinput2" id="doc-ipt-email-1"   value="<?php echo $pay_price;  ?>"    placeholder="请输入付款价格">
                </div>
            </div>



            <div class="am-form-group am-cf">
                <div class="zuo">任务单量：</div>
                <div class="zuo">
                    <input type="text"   name="number" class="myinput am-input-sm myinput2" id="doc-ipt-email-1"   value="<?php echo $number;  ?>"    placeholder="请输入任务单量">
                </div>

                <div class="zuo jiage">每单数量：</div>
                <div class="zuo">
                    <input type="text"   name="each_single" class="myinput am-input-sm myinput2" id="doc-ipt-email-1"   value="<?php echo $each_single;  ?>"    placeholder="请输入每单数量">
                </div>



            </div>


            <div class="am-form-group am-cf">
                <div class="zuo">优惠券：</div>
                <div class="zuo">
                    <input type="text"   name="coupon" class="myinput am-input-sm myinput2 " id="doc-ipt-email-1"   value="<?php echo $coupon;  ?>"    placeholder="请输入优惠券(非必须)">
                </div>

                <div class="zuo jiage">SKU：</div>
                <div class="zuo">
                    <input type="text"   name="sku" class="myinput am-input-sm myinput2 " id="doc-ipt-email-1"   value="<?php echo $sku;  ?>"    placeholder="请输入SKU">
                </div>

            </div>

            <div class="am-form-group am-cf">
                <div class="zuo">备注说明：</div>
                <div class="you">
                    <input type="text"   name="remarks" class="myinput am-input-sm" id="doc-ipt-email-1"   value="<?php echo $remarks;  ?>"    placeholder="请输入备注(非必须)">
                </div>
            </div>


            <div class="am-form-group am-cf">
                <div class="zuo">主图上传：</div>
                <div class="you" style="height: 45px;">
                    <div  class="picbox" style="">
                        <img src="<?php echo base_url();?>/public/assets/image/wsc.png" class="picshow"   style=" " >
                    </div>
                    <a href="javascript:" class="file">上传图片
                        <input type="file" name="uploadFile" class="uploadPicButton" id="upload_file">
                    </a>
                </div>
            </div>
            <div class="am-form-group am-cf  taskbottom" style="">
                <div  class="moneybox" style=" ">
                    <div class="zuo" style="">任务所需本金：<span class="needmoney">0</span></div>
                    <div class="zuo" style=";">任务所需金币：<span class="needgold">0</span></div>
                    <div id="fabu" class=" submit am-btn am-btn-secondary am-radius" style="margin-right: 0px;">再次发布</div>

                </div>
            </div>
        </form>



    </div>


    <!-- 底部模板-->
</div>
</div>
</div>

<div class="foods">
    <ul>
        版权所有@2019.
    </ul>
    <dl>
        <a href="" title="返回头部" class="am-icon-btn am-icon-arrow-up"></a>
    </dl>
</div>
</body>
</html>
<!-- 底部模板-->


    <script>
        var minnub="<?php echo $min; ?>";
        var maxnub="<?php echo $max; ?>";
        var is12="<?php echo $is12; ?>"; //确认现在是否是12点
        $("input").attr("autocomplete","off");
        $("input[name='number']").focus(function () {
            $(this).val("");
        });
        $("input[name='each_single']").focus(function () {
            $(this).val("");
        });


        var picurl="<?php  echo $picurl ?>";
        var picpath="";

        if(picurl!=""){
            $(".picshow").addClass("newpic");
            $(".picshow").attr("src",picurl)
        }

        function uploadPic(){
            var pic = $('#upload_file')[0].files[0];
            var fd = new FormData();
            fd.append('uploadFile', pic);
            var url = "<?php echo base_url(); ?>/Business/uppic";
            $.ajax({
                url:url,
                type:"post",
                dataType:"json",
                // Form数据
                data: fd,
                cache: false,
                contentType: false,
                processData: false,
                success:function(data){
                    if(data.code==0){
                        $(".picshow").attr("src",data.url);
                        $(".picshow").addClass("newpic");

                        $(".picshow").show();
                        $("input[name=pic]").val(data.url);
                        picpath=data.path;
                        return;
                    }
                    layer.msg(data.msg);

                }

            });
        }

    </script>


   <script>

       var on_request=false;
       var type=1;
       var page=1;

       $("#fabu").click(function () {
           fabu()
       });

       function fabu() {
           if (on_request) {
               return;
           }
           var url = "<?php echo base_url(); ?>/Business/SendJdTask";
           var postdata = {};
           var link=$("input[name='link']").val();
           var goods_name=$("input[name='goods_name']").val();
           var shop_name=$("input[name='shop_name']").val();
           var price=$("input[name='price']").val();
           var pay_price=$("input[name='pay_price']").val();
           var number=$("input[name='number']").val();
           var each_single=$("input[name='each_single']").val();
           var keyword=$("input[name='keyword']").val();
           var coupon=$("input[name='coupon']").val();
           var sku=$("input[name='sku']").val();
           var remarks=$("input[name='remarks']").val();
           var type_h=$("input[name='type_h']:checked").val();

           postdata['link'] = link;
           postdata['goods_name'] = goods_name;
           postdata['shop_name'] = shop_name;
           postdata['price'] = price;
           postdata['pay_price'] = pay_price;
           postdata['number'] = number;
           postdata['each_single'] = each_single;
           postdata['keyword'] = keyword;
           postdata['coupon'] = coupon;
           postdata['sku'] = sku;
           postdata['remarks'] = remarks;
           postdata['type_h'] = type_h;

           postdata['releasetime']=$(".datapick1").val();

           var alldata=1;
           var valuekey="";
           $.each(postdata, function (key, value) {
               if(value=="" && key!='coupon' && key!='remarks' ){
                   valuekey=key;
                   alldata=0;
                   return false;
               }
           });
           if(!alldata){
               layer.msg("缺少参数", {icon: 5,time:800});
               $("input[name='"+valuekey+"']").focus();
               on_request = false;
               return;
           }
           postdata['pic'] = picpath;
           postdata['picurl'] = picurl;
           if(number>10){
               var result= confirm("单量超过10 请确认是否正确");
               if(!result){
                   return;
               }

           }
           if(each_single>10){
               var result=  confirm("单量超过10 请确认是否正确");
               if(!result){
                   return;
               }
           }
/*
           if(type_h==2){
               layer.msg("暂时关闭高留评订单");
               return;
           }*/
           if(is12=="1" && type_h==2 ){
               layer.msg("超过12点不能发布高留评单");
               return;
           }

           if(number<minnub && type_h==2){
               layer.msg("高留评单单量必须在10-500之间", {icon: 5,time:800});
               return;
           }
           if(number>maxnub && type_h==2){
               layer.msg("高留评单单量必须在10-500之间", {icon: 5,time:800});
               return;
           }

           fabupost(url,postdata);
       }

       function fabupost(url,postdata)
       {
           on_request = true;
           $.post(url, postdata, function (data) {
               on_request = false;
               if(data.code==0){
                   layer.msg("任务发布成功")
                   window.location.href="<?php echo base_url() ?>"+'/business/pddtasklist' ;
               } else{
                   layer.msg(data.msg)
               }
           },"json");
       }


       $("input[name='each_single']").bind("change",setgold);
       $("input[name='pay_price']").bind("change",setgold);
       $("input[name='number']").bind("change",setgold);
       setgold();


       function setgold(){
           var price=$("input[name='pay_price']").val();
           var number=$("input[name='number']").val();
           var each_single=$("input[name='each_single']").val();
           var needmoney=price*each_single;

           if(needmoney<=0){
               return;
           }
           $(".needmoney").text(needmoney*number);
           var url = "<?php echo base_url(); ?>/Business/getgoldbymoney/1";
           var postdata = {};
           postdata['needmoney'] = needmoney;

           $.post(url, postdata, function (data) {
               on_request = false;

               data.allgold=data.allgold*number;

               $(".needgold").text(data.allgold);
           },"json");

       }






   </script>





